<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Macro BOOST_VMD_ELEM_D</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="Chapter 1. The Variadic Macro Data Library 1.10">
<link rel="up" href="header/boost/vmd/elem_hpp.html" title="Header &lt;boost/vmd/elem.hpp&gt;">
<link rel="prev" href="BOOST_VMD_ELEM.html" title="Macro BOOST_VMD_ELEM">
<link rel="next" href="header/boost/vmd/empty_hpp.html" title="Header &lt;boost/vmd/empty.hpp&gt;">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="BOOST_VMD_ELEM.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="header/boost/vmd/elem_hpp.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="header/boost/vmd/empty_hpp.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="BOOST_VMD_ELEM_D"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Macro BOOST_VMD_ELEM_D</span></h2>
<p>BOOST_VMD_ELEM_D — Accesses an element of a sequence. Re-entrant version. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="header/boost/vmd/elem_hpp.html" title="Header &lt;boost/vmd/elem.hpp&gt;">boost/vmd/elem.hpp</a>&gt;

</span>BOOST_VMD_ELEM_D(d, elem, ...)</pre></div>
<div class="refsect1">
<a name="idm45306168242784"></a><h2>Description</h2>
<p>d = The next available BOOST_PP_WHILE iteration. <br>
 elem = A sequence element number. From 0 to sequence size - 1. <br>
 ... = Variadic parameters.</p>
<p>The first variadic parameter is required and is the sequence to access. Further variadic parameters are all optional.</p>
<p>With no further variadic parameters the macro returns the particular element in the sequence. If the element number is outside the bounds of the sequence macro access fails and the macro turns emptiness.</p>
<p>Optional parameters determine what it means that an element is successfully accessed as well as what data is returned by the macro.</p>
<p>Filters: specifying a VMD type tells the macro to return the element only if it is of the VMD type specified, else macro access fails. If more than one VMD type is specified as an optional parameter the last one specified is the filter.</p>
<p>Matching Identifiers: If the filter is specified as the identifier type, BOOST_VMD_TYPE_IDENTIFIER, optional parameters which are identifiers specify that the element accessed must match one of the identifiers else access fails. The identifiers may be specified multiple times as single optional parameters or once as a tuple of identifier parameters. If the identifiers are specified as single optional parameters they cannot be any of the specific BOOST_VMD_ optional parameters in order to be recognized as matching identifiers. Normally this should never be the case. The only situation where this could occur is if the VMD types, which are filters, are used as matching identifiers; in this case the matching identifiers need to be passed as a tuple of identifier parameters so they are not treated as filters.</p>
<p>Filters and matching identifiers change what it means that an element is successfully accessed. They do not change what data is returned by the macro. The remaining optional parameters do not change what it means that an element is successfully accessed but they do change what data is returned by the macro.</p>
<pre class="programlisting"><span class="identifier">Splitting</span><span class="special">:</span> <span class="identifier">Splitting</span> <span class="identifier">allows</span> <span class="identifier">the</span> <span class="identifier">macro</span> <span class="identifier">to</span> <span class="keyword">return</span> <span class="identifier">the</span> <span class="identifier">rest</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">sequence</span>
         <span class="identifier">after</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">accessed</span><span class="special">.</span>

         <span class="identifier">If</span> <span class="identifier">BOOST_VMD_RETURN_AFTER</span> <span class="identifier">is</span> <span class="identifier">specified</span> <span class="identifier">the</span> <span class="keyword">return</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">tuple</span>
         <span class="identifier">with</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">accessed</span> <span class="identifier">as</span> <span class="identifier">the</span> <span class="identifier">first</span> <span class="identifier">tuple</span> <span class="identifier">parameter</span> <span class="identifier">and</span> <span class="identifier">the</span> <span class="identifier">rest</span> <span class="identifier">of</span>
         <span class="identifier">the</span> <span class="identifier">sequence</span> <span class="identifier">as</span> <span class="identifier">the</span> <span class="identifier">second</span> <span class="identifier">tuple</span> <span class="identifier">parameter</span><span class="special">.</span> <span class="identifier">If</span> <span class="identifier">element</span> <span class="identifier">access</span> <span class="identifier">fails</span> 
         <span class="identifier">both</span> <span class="identifier">tuple</span> <span class="identifier">parameters</span> <span class="identifier">are</span> <span class="identifier">empty</span><span class="special">.</span> 
         
         <span class="identifier">If</span> <span class="identifier">BOOST_VMD_RETURN_ONLY_AFTER</span>
         <span class="identifier">is</span> <span class="identifier">specified</span> <span class="identifier">the</span> <span class="keyword">return</span> <span class="identifier">is</span> <span class="identifier">the</span> <span class="identifier">rest</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">sequence</span> <span class="identifier">after</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">accessed</span>
         <span class="identifier">found</span><span class="special">.</span> <span class="identifier">If</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">access</span> <span class="identifier">fails</span> <span class="identifier">the</span> <span class="keyword">return</span> <span class="identifier">is</span> <span class="identifier">emptiness</span><span class="special">.</span> 
         
         <span class="identifier">If</span> <span class="identifier">BOOST_VMD_RETURN_NO_AFTER</span><span class="special">,</span> <span class="identifier">the</span> <span class="keyword">default</span><span class="special">,</span> <span class="identifier">is</span> <span class="identifier">specified</span> <span class="identifier">no</span> <span class="identifier">splitting</span>
         <span class="identifier">occurs</span><span class="special">.</span> 
         
         <span class="identifier">If</span> <span class="identifier">more</span> <span class="identifier">than</span> <span class="identifier">one</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">splitting</span> <span class="identifier">identifiers</span> <span class="identifier">are</span> <span class="identifier">specified</span>
         <span class="identifier">the</span> <span class="identifier">last</span> <span class="identifier">one</span> <span class="identifier">specified</span> <span class="identifier">determines</span> <span class="identifier">the</span> <span class="identifier">splitting</span><span class="special">.</span>
         
 <span class="identifier">Return</span> <span class="identifier">Type</span><span class="special">:</span> <span class="identifier">The</span> <span class="identifier">element</span> <span class="identifier">accessed</span> <span class="identifier">can</span> <span class="identifier">be</span> <span class="identifier">changed</span> <span class="identifier">to</span> <span class="keyword">return</span> <span class="identifier">both</span> <span class="identifier">the</span> <span class="identifier">type</span>
         <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">as</span> <span class="identifier">well</span> <span class="identifier">as</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">data</span> <span class="identifier">with</span> <span class="identifier">optional</span> <span class="keyword">return</span> <span class="identifier">type</span> 
         <span class="identifier">parameters</span><span class="special">.</span> <span class="identifier">When</span> <span class="identifier">a</span> <span class="identifier">type</span> <span class="identifier">is</span> <span class="identifier">returned</span><span class="special">,</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">accessed</span> <span class="identifier">which</span> <span class="identifier">is</span> <span class="identifier">returned</span> <span class="identifier">becomes</span> <span class="identifier">a</span>
         <span class="identifier">two</span><span class="special">-</span><span class="identifier">element</span> <span class="identifier">tuple</span> <span class="identifier">where</span> <span class="identifier">the</span> <span class="identifier">type</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">accessed</span> <span class="identifier">is</span> <span class="identifier">the</span> <span class="identifier">first</span> <span class="identifier">tuple</span> <span class="identifier">element</span> <span class="identifier">and</span> <span class="identifier">the</span> <span class="identifier">element</span>
         <span class="identifier">data</span> <span class="identifier">itself</span> <span class="identifier">is</span> <span class="identifier">the</span> <span class="identifier">second</span> <span class="identifier">tuple</span> <span class="identifier">element</span><span class="special">.</span> <span class="identifier">If</span> <span class="identifier">the</span> <span class="identifier">macro</span> <span class="identifier">fails</span> <span class="identifier">to</span> <span class="identifier">access</span> <span class="identifier">the</span>
         <span class="identifier">element</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">access</span> <span class="identifier">returned</span> <span class="identifier">is</span> <span class="identifier">emptiness</span> <span class="identifier">and</span> <span class="identifier">not</span> <span class="identifier">a</span> <span class="identifier">tuple</span><span class="special">.</span> 
         
         <span class="identifier">If</span> <span class="identifier">BOOST_VMD_RETURN_NO_TYPE</span><span class="special">,</span> <span class="identifier">the</span> <span class="keyword">default</span><span class="special">,</span> <span class="identifier">is</span> <span class="identifier">specified</span> <span class="identifier">no</span> <span class="identifier">type</span> <span class="identifier">is</span> <span class="identifier">returned</span> 
         <span class="identifier">as</span> <span class="identifier">part</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">accessed</span><span class="special">.</span> 
         
         <span class="identifier">If</span> <span class="identifier">BOOST_VMD_RETURN_TYPE</span> <span class="identifier">is</span> <span class="identifier">specified</span> <span class="identifier">the</span> <span class="identifier">specific</span> <span class="identifier">type</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">element</span>
         <span class="identifier">is</span> <span class="identifier">returned</span> <span class="identifier">in</span> <span class="identifier">the</span> <span class="identifier">tuple</span><span class="special">.</span> 
         
         <span class="identifier">If</span> <span class="identifier">BOOST_VMD_RETURN_TYPE_ARRAY</span> <span class="identifier">is</span> <span class="identifier">specified</span>
         <span class="identifier">an</span> <span class="identifier">array</span> <span class="identifier">type</span> <span class="identifier">is</span> <span class="identifier">returned</span> <span class="keyword">if</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">is</span> <span class="identifier">an</span> <span class="identifier">array</span><span class="special">,</span> <span class="keyword">else</span> <span class="identifier">a</span> <span class="identifier">tuple</span>
         <span class="identifier">type</span> <span class="identifier">is</span> <span class="identifier">returned</span> <span class="keyword">if</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">tuple</span><span class="special">,</span> <span class="keyword">else</span> <span class="identifier">the</span> <span class="identifier">actual</span> <span class="identifier">type</span>
         <span class="identifier">is</span> <span class="identifier">returned</span> <span class="keyword">for</span> <span class="identifier">non</span><span class="special">-</span><span class="identifier">tuple</span> <span class="identifier">data</span><span class="special">.</span> 
         
         <span class="identifier">If</span> <span class="identifier">BOOST_VMD_RETURN_TYPE_LIST</span> <span class="identifier">is</span> <span class="identifier">specified</span>
         <span class="identifier">a</span> <span class="identifier">list</span> <span class="identifier">type</span> <span class="identifier">is</span> <span class="identifier">returned</span> <span class="keyword">if</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">list</span><span class="special">,</span> <span class="keyword">else</span> <span class="identifier">a</span> <span class="identifier">tuple</span>
         <span class="identifier">type</span> <span class="identifier">is</span> <span class="identifier">returned</span> <span class="keyword">if</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">tuple</span><span class="special">,</span> <span class="keyword">else</span> <span class="identifier">the</span> <span class="identifier">actual</span> <span class="identifier">type</span>
         <span class="identifier">is</span> <span class="identifier">returned</span> <span class="keyword">for</span> <span class="identifier">non</span><span class="special">-</span><span class="identifier">tuple</span> <span class="identifier">data</span><span class="special">.</span> 
         
         <span class="identifier">If</span> <span class="identifier">BOOST_VMD_RETURN_TYPE_TUPLE</span> <span class="identifier">is</span> <span class="identifier">specified</span>
         <span class="identifier">a</span> <span class="identifier">tuple</span> <span class="identifier">type</span> <span class="identifier">is</span> <span class="identifier">returned</span> <span class="keyword">for</span> <span class="identifier">all</span> <span class="identifier">tuple</span><span class="special">-</span><span class="identifier">like</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">else</span> <span class="identifier">the</span> <span class="identifier">actual</span> <span class="identifier">type</span>
         <span class="identifier">is</span> <span class="identifier">returned</span> <span class="keyword">for</span> <span class="identifier">non</span><span class="special">-</span><span class="identifier">tuple</span> <span class="identifier">data</span><span class="special">.</span> <span class="identifier">If</span> <span class="identifier">more</span> <span class="identifier">than</span> <span class="identifier">one</span> <span class="keyword">return</span> <span class="identifier">type</span> <span class="identifier">optional</span>
         <span class="identifier">parameter</span> <span class="identifier">is</span> <span class="identifier">specified</span> <span class="identifier">the</span> <span class="identifier">last</span> <span class="identifier">one</span> <span class="identifier">specified</span> <span class="identifier">determines</span> <span class="identifier">the</span> <span class="keyword">return</span> <span class="identifier">type</span><span class="special">.</span>
         
         <span class="identifier">If</span> <span class="identifier">a</span> <span class="identifier">filter</span> <span class="identifier">is</span> <span class="identifier">specified</span> <span class="identifier">optional</span> <span class="keyword">return</span> <span class="identifier">type</span> <span class="identifier">parameters</span> <span class="identifier">are</span> <span class="identifier">ignored</span> <span class="identifier">and</span>
         <span class="identifier">the</span> <span class="keyword">default</span> <span class="identifier">BOOST_VMD_RETURN_NO_TYPE</span> <span class="identifier">is</span> <span class="identifier">in</span> <span class="identifier">effect</span><span class="special">.</span>
         
 <span class="identifier">Index</span><span class="special">:</span>  <span class="identifier">If</span> <span class="identifier">the</span> <span class="identifier">filter</span> <span class="identifier">is</span> <span class="identifier">specified</span> <span class="identifier">as</span> <span class="identifier">the</span> <span class="identifier">identifier</span> <span class="identifier">type</span><span class="special">,</span> <span class="identifier">BOOST_VMD_TYPE_IDENTIFIER</span><span class="special">,</span>
         <span class="identifier">and</span> <span class="identifier">matching</span> <span class="identifier">identifiers</span> <span class="identifier">are</span> <span class="identifier">specified</span><span class="special">,</span> <span class="identifier">an</span> <span class="identifier">index</span> <span class="identifier">parameter</span> <span class="identifier">specifies</span> <span class="identifier">that</span> <span class="identifier">the</span>
         <span class="identifier">numeric</span> <span class="identifier">index</span><span class="special">,</span> <span class="identifier">starting</span> <span class="identifier">with</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">matching</span> <span class="identifier">identifier</span> <span class="identifier">found</span><span class="special">,</span> <span class="identifier">be</span> <span class="identifier">returned</span>
         <span class="identifier">as</span> <span class="identifier">part</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">result</span><span class="special">.</span> 
         
         <span class="identifier">If</span> <span class="identifier">BOOST_VMD_RETURN_INDEX</span> <span class="identifier">is</span> <span class="identifier">specified</span> <span class="identifier">an</span> <span class="identifier">index</span> <span class="identifier">is</span> <span class="identifier">returned</span>
         <span class="identifier">as</span> <span class="identifier">part</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">result</span><span class="special">.</span> 
         
         <span class="identifier">If</span> <span class="identifier">BOOST_VMD_RETURN_NO_INDEX</span><span class="special">,</span> <span class="identifier">the</span> <span class="keyword">default</span><span class="special">,</span> <span class="identifier">is</span> <span class="identifier">specified</span>
         <span class="identifier">no</span> <span class="identifier">index</span> <span class="identifier">is</span> <span class="identifier">returned</span> <span class="identifier">as</span> <span class="identifier">part</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">result</span><span class="special">.</span> 
         
         <span class="identifier">If</span> <span class="identifier">both</span> <span class="identifier">are</span> <span class="identifier">specified</span> <span class="identifier">the</span> <span class="identifier">last</span> <span class="identifier">one</span> <span class="identifier">specified</span> <span class="identifier">determines</span> <span class="identifier">the</span> <span class="identifier">index</span> <span class="identifier">parameter</span><span class="special">.</span> 
         
         <span class="identifier">When</span> <span class="identifier">an</span> <span class="identifier">index</span> <span class="identifier">is</span> <span class="identifier">returned</span> <span class="identifier">as</span> <span class="identifier">part</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">result</span><span class="special">,</span> <span class="identifier">the</span> <span class="identifier">result</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">tuple</span> <span class="identifier">where</span> <span class="identifier">the</span> 
         <span class="identifier">element</span> <span class="identifier">accessed</span> <span class="identifier">is</span> <span class="identifier">the</span> <span class="identifier">first</span> <span class="identifier">tuple</span> <span class="identifier">parameter</span> <span class="identifier">and</span> <span class="identifier">the</span> <span class="identifier">index</span> <span class="identifier">is</span> <span class="identifier">the</span> <span class="identifier">last</span> <span class="identifier">tuple</span> <span class="identifier">parameter</span><span class="special">.</span> 
         <span class="identifier">If</span> <span class="identifier">element</span> <span class="identifier">access</span> <span class="identifier">fails</span> <span class="identifier">the</span> <span class="identifier">index</span> <span class="identifier">is</span> <span class="identifier">empty</span><span class="special">.</span> <span class="identifier">If</span> <span class="identifier">there</span> <span class="identifier">is</span> <span class="identifier">no</span> <span class="identifier">BOOST_VMD_TYPE_IDENTIFIER</span> 
         <span class="identifier">filter</span> <span class="identifier">or</span> <span class="keyword">if</span> <span class="identifier">there</span> <span class="identifier">are</span> <span class="identifier">no</span> <span class="identifier">matching</span> <span class="identifier">identifiers</span> <span class="identifier">the</span> <span class="identifier">BOOST_VMD_RETURN_INDEX</span> <span class="identifier">is</span> <span class="identifier">ignored</span> 
         <span class="identifier">and</span> <span class="identifier">no</span> <span class="identifier">index</span> <span class="identifier">is</span> <span class="identifier">returned</span> <span class="identifier">as</span> <span class="identifier">part</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">result</span><span class="special">.</span>
</pre>
<p>returns = With no optional parameters the element accessed is returned, or emptiness if element is outside the bounds of the sequence. Filters and matching identifiers can change the meaning of whether the element accessed is returned or failure occurs, but whenever failure occurs emptiness is returned as the element access part of that failure, else the element accessed is returned. Return type optional parameters, when filters are not used, return the element accessed as a two-element tuple where the first tuple element is the type and the second tuple element is the data; if the element is not accessed then emptiness is returned as the element access and not a tuple. Splitting with BOOST_VMD_RETURN_AFTER returns a tuple where the element accessed is the first tuple element and the rest of the sequence is the second tuple element. Splitting with BOOST_VMD_RETURN_ONLY_AFTER returns the rest of the sequence after the element accessed or emptiness if the element can not be accessed. Indexing returns the index as part of the output only if filtering with BOOST_VMD_TYPE_IDENTIFIER is specified and matching identifiers are specified. When the index is returned with BOOST_VMD_RETURN_AFTER it is the third element of the tuple returned, else it is the second element of a tuple where the element accessed is the first element of the tuple. </p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2010-2017 Tropic Software
      East Inc</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="BOOST_VMD_ELEM.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="header/boost/vmd/elem_hpp.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="header/boost/vmd/empty_hpp.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
